#include "INetworkSnapshotDumper.h"

struct NetworkSnapshotTextDumper: INetworkSnapshotDumper {
  virtual void dump(std::ostream& out, const NetworkSnapshotPtr snapshot) {
    Networks::const_iterator netIt, netEnd;
    netIt = snapshot->getNetworks().begin();
    netEnd = snapshot->getNetworks().end();
    
    for(; netIt != netEnd; ++netIt) {
      NetRouters::const_iterator routeIt, routeEnd;
      out << "Network " << netIt->getId() << std::endl;
      routeIt = netIt->getRouters().begin();
      routeEnd = netIt->getRouters().end();
      for(; routeIt != routeEnd; ++routeIt) {
        NetInterfaces::const_iterator interfIt, interfEnd;
        out << "  Router" << std::endl;
        out << routeIt->getDescription() << std::endl;
        out << std::endl << std::endl;
        interfIt = routeIt->getInterfaces().begin();
        interfEnd = routeIt->getInterfaces().end();

        for(; interfIt != interfEnd; ++interfIt) {
          NetNodes::const_iterator subNetNodeIt, subNetNodeItEnd;
          out << "    Interface   " << interfIt->getAddress()  << std::endl
              << "      name:     " << interfIt->getName()     << std::endl 
              << "      inBytes:  " << interfIt->getInBytes()  << std::endl 
              << "      outBytes: " << interfIt->getOutBytes() << std::endl; 
          const SubNet& subNet = netIt->getSubNetById(interfIt->getSubNetId());
          out << "      Subnet:   " << subNet.getId() << std::endl;
          subNetNodeIt = subNet.getNodes().begin();
          subNetNodeItEnd = subNet.getNodes().end();
          for(; subNetNodeIt != subNetNodeItEnd; ++subNetNodeIt) {
            out << "        " << subNetNodeIt->getAddress() 
                << " " << subNetNodeIt->getName() << std::endl;
          }
        }
      }
    }
  }
};
